package com.yx.yinshanjinniu.adapters;

import android.content.Context;
import android.view.View;
import android.widget.ImageView;
import android.widget.LinearLayout;
import android.widget.TextView;

import com.bumptech.glide.Glide;
import com.yx.yinshanjinniu.R;
import com.yx.yinshanjinniu.base.BaseRVAdapter;
import com.yx.yinshanjinniu.base.BaseRVHolder;
import com.yx.yinshanjinniu.bean.WelfareTaskBean;

import java.util.List;

public class WelfareAdapter extends BaseRVAdapter {
    public WelfareAdapter(Context context, List list) {
        super(context, list);
    }

    @Override
    public int onCreateViewLayoutID(int viewType) {
        return R.layout.item_welfare;
    }

    @Override
    public void onBindView(BaseRVHolder holder, int position) {
        LinearLayout ll_prize = holder.getViewHolder().get(R.id.ll_prize);
        ImageView iconImg = holder.getViewHolder().get(R.id.welfare_item_icon);
        TextView typeImg = holder.getViewHolder().get(R.id.welfare_task_type);
        TextView title_tv = holder.getViewHolder().get(R.id.welfare_item_title_text);
        TextView integral_tv = holder.getViewHolder().get(R.id.welfare_item_integral_text);
        LinearLayout ll_btn_prize = holder.getViewHolder().get(R.id.ll_btn_prize);
        TextView tv_btn_prize = holder.getViewHolder().get(R.id.tv_btn_prize);
//        TextView process_tv = holder.getViewHolder().get(R.id.welfare_item_process);

        WelfareTaskBean.DayBean dayBean = (WelfareTaskBean.DayBean) mList.get(position);
        if (dayBean.getTaskStatus().equals("0")) {
            typeImg.setText(dayBean.getTaskProgress() + "/" + dayBean.getTarget());
            ll_prize.setVisibility(View.VISIBLE);
            ll_btn_prize.setVisibility(View.GONE);
            typeImg.setVisibility(View.VISIBLE);
            typeImg.setBackgroundResource(R.drawable.shape_16dp_black);
//            typeImg.setImageResource(R.drawable.welfare_finish);
        } else if (dayBean.getTaskStatus().equals("1")) {
            tv_btn_prize.setText("+" + dayBean.getReward());
            ll_prize.setVisibility(View.GONE);
            ll_btn_prize.setVisibility(View.VISIBLE);
            typeImg.setVisibility(View.GONE);
            typeImg.setBackgroundResource(R.drawable.shape_16dp_black);
//            typeImg.setImageResource(R.drawable.welfare_pickup);
        } else if (dayBean.getTaskStatus().equals("2")) {
            tv_btn_prize.setText("+" + dayBean.getReward());
            ll_prize.setVisibility(View.GONE);
            ll_btn_prize.setVisibility(View.VISIBLE);
            typeImg.setVisibility(View.GONE);
            ll_btn_prize.setBackgroundResource(R.drawable.shape_16dp_b7b7b7);
//            typeImg.setImageResource(R.drawable.welfare_over);
        }
        title_tv.setText(dayBean.getTitle());
        integral_tv.setText("+" + dayBean.getReward() + "积分");
//        process_tv.setText("进度: "+dayBean.getTaskProgress()+"/"+dayBean.getTarget());
        Glide.with(mContext).load(dayBean.getIcon()).into(iconImg);
    }
}
